# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /cvs/zport/sci-mathematics/spin/spin-4.2.7.ebuild,v 1.2 2007/07/11 14:28:02 zechs Exp $

inherit eutils

MY_PV=${PV//\./}
XSPIN_PV="4.2"
DESCRIPTION="Spin - a popular open-source software tool used for the formal verification of distributed software systems"
HOMEPAGE="http://spinroot.com/"
SRC_URI="http://spinroot.com/spin/Src/spin${MY_PV}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="x86 sparc"

IUSE="xspin"
DEPEND="xspin? ( dev-lang/tcl dev-lang/tk )"

src_unpack() {
	unpack ${A}
}

src_compile() {
	cd ${WORKDIR}/Spin/Src${PV}
	make
}

src_install() {
	dodir /usr/bin /usr/share/man/man1 /usr/share/doc/${P}

	exeinto /usr/bin
	doexe ${WORKDIR}/Spin/Src${PV}/spin
	doman ${WORKDIR}/Spin/Man/spin.1
	dodoc ${WORKDIR}/Spin/Doc/*

	if use xspin; then
		sed 's/#!\/bin\/sh/#!\/usr\/bin\/wish -f/' ${WORKDIR}/Spin/Xspin${XSPIN_PV}/xspin${MY_PV}.tcl | sed '/exec wish c:\/cygwin\/bin\/xspin/d' | sed 's/time .\/pan/.\/pan/' > ${WORKDIR}/Spin/Xspin${XSPIN_PV}/xspin
		doexe ${WORKDIR}/Spin/Xspin${XSPIN_PV}/xspin
	fi
}
